#
# Copyright (c) 2014 CodiLime, Inc. All rights reserved.
#

# -*- mode: python; -*-

Import('BuildEnv')
import os
import platform

env = BuildEnv.Clone()

env.Append(CPPPATH = [env['TOP'],
                      env['TOP'] + '/base',
                      env['TOP'] + '/io',
                      env['TOP'] + '/bfd',
                     ])
env.Append(LIBPATH = ['#/' + Dir('..').path,
                      '.'
                     ])

env.Prepend(LIBS = ['bfd_udp', 'bfd', 'gunit', 'io', 'sandesh', 'sandeshvns',
                    'process_info', 'task_test', 'base', 'http', 'io', 'ssl',
                    'crypto', 'http_parser', 'curl', 'pugixml',
                    'boost_program_options', 'boost_thread'])

if platform.system() != 'Darwin':
    env.Append(LIBS=['rt'])

except_env = env.Clone()
except_env.CppEnableExceptions()

config_test_env = env.Clone()
# config_test_env.Append(LIBPATH = ['../../ifmap/test'])
# config_test_env.Prepend(LIBS = ['ifmap_test_util'])

bfd_parser_test = env.UnitTest('bfd_parser_test',
                            ['bfd_parser_test.cc'])
env.Alias('src/bfd:bfd_parser_test', bfd_parser_test)

bfd_udp_connection_test = env.UnitTest('bfd_udp_connection_test',
                            ['bfd_udp_connection_test.cc'])
env.Alias('src/bfd:bfd_udp_connection_test', bfd_udp_connection_test)

bfd_state_machine_test = env.UnitTest('bfd_state_machine_test',
                            ['bfd_state_machine_test.cc'])
env.Alias('src/bfd:bfd_state_machine_test', bfd_state_machine_test)

bfd_server_test = env.UnitTest('bfd_server_test',
                            ['bfd_server_test.cc'])
env.Alias('src/bfd:bfd_server_test', bfd_server_test)

bfd_session_test = env.UnitTest('bfd_session_test',
                            ['bfd_session_test.cc'])
env.Alias('src/bfd:bfd_session_test', bfd_session_test)

bfd_external_test = env.UnitTest('bfd_external_test',
                            ['bfd_external_test.cc'])
env.Alias('src/bfd:bfd_external_test', bfd_external_test)

bfd_client_test = env.UnitTest('bfd_client_test', ['bfd_client_test.cc'])
env.Alias('src/bfd:bfd_client_test', bfd_client_test)

# All Tests
test_suite = [
    bfd_client_test,
    bfd_parser_test,
    bfd_session_test,
    bfd_state_machine_test,
    bfd_udp_connection_test,
]

flaky_test_suite = [
    bfd_server_test,
#   bfd_external_test,
]

test = env.TestSuite('bfd-test', test_suite)
env.Alias('controller/src/bfd:test',
          [test, 'controller/src/bfd/rest_api:test'])

flaky_test = env.TestSuite('bfd-flaky-test', flaky_test_suite)
env.Alias('controller/src/bfd:flaky-test',
          [flaky_test, 'controller/src/bfd/rest_api:flaky-test'])

Return('test_suite')
